//
//  ViewController.m
//  LBPageViewController
//
//  Created by 刘文扬 on 2017/9/20.
//  Copyright © 2017年 lianj. All rights reserved.
//

#import "ViewController.h"
#import "LBPageViewController.h"
#import "Masonry.h"
#import "UINavigationController+TZPopGesture.h"

@interface ViewController ()

/** pageViewController*/
@property(nonatomic,strong)LBPageViewController *pageViewController;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
    [self.pageViewController.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
//    [self tz_addPopGestureToView:self.pageViewController.pageScrollView];
    // Do any additional setup after loading the view, typically from a nib.
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)action:(id)sender
{
    
    [self.pageViewController selectPageIndex:0];
}

-(LBPageViewController *)pageViewController
{
    if (_pageViewController == nil) {
        
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor yellowColor];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(100, 100, 100, 100);
        button.backgroundColor = [UIColor blueColor];
        
        [button addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
        
        [view addSubview:button];
        
        UIView *view2 = [[UIView alloc] init];
        
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
        button1.frame = CGRectMake(100, 100, 100, 100);
        
        view2.backgroundColor = [UIColor blueColor];
        button1.backgroundColor = [UIColor yellowColor];
        [button1 addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:button1];
        _pageViewController = [[LBPageViewController alloc] initWithViewOrViewControllers:@[view2,[UIViewController new],view] titles:@[@"测试1是打发",@"测试",@"测试嗯嗯"] sliderConfig:^(LBPageMenu *slider) {
            slider.titleFontSize = 11;
            slider.sliderColor = [UIColor redColor];
        }];
        
        _pageViewController.didChangePageBlock = ^(id viewOrViewController, NSInteger index){
//            NSLog(@"%ld",index);
        };
        
        
        
    }
    return _pageViewController;
}


@end
